package o;

import com.huawei.appgallery.foundation.card.base.bean.AppInfoBean;
import com.huawei.appmarket.framework.startevents.roam.RoamFragment.a;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class RoamDataManager {
    private static RoamDataManager manager;
    private List<AppInfoBean> listBeans = new ArrayList();

    public static RoamDataManager build() {
        if (manager == null) {
            manager = new RoamDataManager();
        }
        return manager;
    }

    public static void destory() {
        manager = null;
    }

    public List<AppInfoBean> getAppInfoBean() {
        return this.listBeans;
    }

    public void ˎ(List<AppInfoBean> list) {
        if (!CollectCheck.isEmpty((List) list)) {
            List arrayList = new ArrayList();
            for (AppInfoBean appInfoBean : getSupportGMSBean(list)) {
                if (!((cdg) cdb.ॱ(cdg.class)).ॱॱ(appInfoBean.ˏॱ())) {
                    appInfoBean.ˏ(0);
                }
                arrayList.add(appInfoBean);
            }
            Collections.sort(arrayList, new a());
            this.listBeans = arrayList;
        } else if (Logger.ˎ()) {
            Logger.ˏ("RoamDataManager", "setData appList of startuprequest is empty.");
        }
    }

    public boolean isNotEmpty() {
        if (this.listBeans.isEmpty()) {
            return false;
        }
        return true;
    }

    private List<AppInfoBean> getSupportGMSBean(List<AppInfoBean> list) {
        if (list == null || CollectCheck.isEmpty((List) list)) {
            return list;
        }
        List<AppInfoBean> arrayList = new ArrayList();
        for (int i = 0; i < list.size(); i++) {
            AppInfoBean appInfoBean = (AppInfoBean) list.get(i);
            if (!isNotSupportGMS(appInfoBean)) {
                arrayList.add(appInfoBean);
            }
        }
        return arrayList;
    }

    private boolean isNotSupportGMS(AppInfoBean appInfoBean) {
        if (appInfoBean == null) {
            return true;
        }
        boolean ˏ = ((cdg) cdb.ॱ(cdg.class)).ˏ(appInfoBean.ˏॱ(), false, 0);
        if (((cdg) cdb.ॱ(cdg.class)).ˎ(appInfoBean.ˏॱ(), false, 0) || ˏ) {
            return true;
        }
        if (HcridSession.ˋ().appsstoreGMSSupport() || 1 != appInfoBean.getGmsSupportFlag()) {
            return false;
        }
        return true;
    }
}
